﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LIMS.Entities;
using LIMS.DataAccess;
using System.Collections;
using System.Reflection;
using Castle.Core.Logging;
using NHibernate.Criterion;

namespace LIMS.Service
{
    public class HeadsManagementService : IHeadsManagementService
    {
        //Private DBA interfaces
        private IDaoFactory oDBFactory;
        private IHeadDAO oHeadsDBA;
        private ILogger logger;
        
        //Constructor
        public HeadsManagementService(IDaoFactory oDBOp, ILogger oLogger)
        {
            this.oDBFactory = oDBOp;
            this.oHeadsDBA = oDBFactory.GetHeadDAO();
            this.logger = oLogger;
        }
        #region IHeadsManagementService Members

        public List<Heads> GetAllHeads()
        {
            List<Heads> myHeadss = new List<Heads>();// oHeadsDBA.GetAll();


            try
            {
                ICriterion oCriteria = Expression.Eq("Status", Resource.ACTIVE_STATUS);
                myHeadss = oHeadsDBA.GetByCriteria(oCriteria);
            }
            catch (Exception ex)
            {
                logger.Error("Error while getting all user Heads.", ex);
                //    return null;
            }
            return myHeadss;
        }

        public bool Save(Heads newHeads)
        {
            return oHeadsDBA.QuickSaveOrUpdate(ref newHeads);
        }

        public bool Delete(Heads dHeads)
        {
            return oHeadsDBA.QuickDelete(dHeads);
        }

        #endregion

        #region IHeadsManagementService Members

        public List<Heads> GetAllHeadsByDepartmentId(int iDepartmentId)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
